package com.cs.study.homework._0316;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.*;

public class Demo3 {
    public static void main(String[] args) {
        Map<User, String> map = new HashMap<>();
        map.put( new User("zs", 18), "zs");
        map.put( new User("ls", 19), "ls");
        map.put( new User("wu", 20), "wu");
        map.put(new User("zl", 21), "zl");
        map.put( new User("aa", 18), "aa");

        System.out.println(map);


    }
}

@Data
@AllArgsConstructor
@NoArgsConstructor
class User{
    String name;
    int age;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return age == user.age;
    }

    @Override
    public int hashCode() {
        return Objects.hash();
    }
}
